﻿Ext.define('app.prm.inquiry.Index', {
    extend: 'Ext.grid.Panel',
    border: false,
    viewConfig: {
        enableTextSelection: true //可以复制单元格文字
    },
    controller: 'inquiry',
    requires: ['app.prm.inquiry.InquiryController', 'app.prm.inquiry.ViewModel'],
    viewModel: {
        type: 'inquiryModel'
    },
    initComponent: function () {
        var me = this;

        me.tbar = [
            { text: localize('Add'), glyph: 0xf067, handler: 'onAdd' },
            '->',
            {
                text: '查询', glyph: 0xf002, menu:
                {
                    xtype: 'menu',
                    plain: true,
                    items: Ext.create("app.prm.inquiry.Search")
                }
            },
            {
                text: localize('Refresh'),
                glyph: 0xf021, handler: function () {
                    me.store.load();
                }
            }
        ];
        me.store = Ext.create("app.ux.PageInquiryStore",
            {
                url: '/api/services/app/Inquiry/GetAll'
            }
            );
        me.pagingBar = Ext.create({
            xtype: 'pagingtoolbar',
            store: me.store,   // same store GridPanel is using
            dock: 'bottom',
            displayInfo: true
        });
        me.dockedItems = [me.pagingBar]

        me.callParent();
    },
    forceFit: false,
    columns: [
        {
            xtype: 'actioncolumn',
            width: 50,
            header: localize('Operating'),
            items: [
            {
                icon: '/Content/images/page_go.png',
                tooltip: '详细',
                handler: 'onEditProject'
            }]
        },
        {
            text: "#", xtype: 'rownumberer', width: 50
        },
        { header: '项目流水号', dataIndex: 'projectNo' },
        { header: '九洲代号', dataIndex: 'inquiryNo' },
         { header: '状态', dataIndex: 'statusStr' },
         { header: '销售', dataIndex: 'createBy' },
         { header: '负责人', dataIndex: 'adminName' },
        { header: '客户名称', dataIndex: 'customerName' },
        { header: '日期', dataIndex: 'createOn' ,renderer:Ext.util.Format.dateRenderer('Y-m-d')},
        { header: '项目名称', dataIndex: 'projectName' },
        { header: '项目类型', dataIndex: 'projectType' },
        { header: '产品号', dataIndex: 'productName' },
        { header: '化学名', dataIndex: 'subName' },
        { header: 'CAS', dataIndex: 'subCas' },
        { header: '要求交期', dataIndex: 'targetDate', renderer: Ext.util.Format.dateRenderer('Y-m-d') }
    ],
    listeners: {
        afterrender: 'onInit',
        rowdblclick: 'onDbClick'
    }
})